package com.cloud.open.constant;

import com.cloud.common.bean.ResultInfo;
import lombok.Getter;

public enum ErrorEnum {

    ID_NOT_NULL(600, "ID不允许为空"),
    NAME_EXIST(601, "名称已存在"),
    URI_EXIST(602, "路径已存在"),
    URI_INCORRECT(603, "路径不正确"),
    INVALID_STATUS(604, "无效状态值"),
    APP_NOT_EXIST(605, "应用不存在"),
    APPID_NOT_EXIST(606, "应用ID不存在"),
    APPSECRET_INCORRECT(607, "应用密钥不正确"),
    RESOURCE_NOT_EXIST(608, "资源不存在"),
    PLEASE_ADD_RESOURCE(609, "请先添加资源"),
    PLEASE_ADD_RESOURCE_TYPE(610, "请先添加资源分类"),
    IP_INCORRECT(611, "IP格式不正确");


    @Getter
    private int code;

    @Getter
    private String message;

    public <T> ResultInfo<T> resultInfo() {
        return ResultInfo.failure().setCode(code).setMessage(message);
    }

    ErrorEnum(int code, String message) {
        this.code = code;
        this.message = message;
    }

}
